package cz.af.portletExams.backend;

import cz.af.portletExams.model.Exam;
import cz.af.portletExams.model.Subject;
import org.joda.time.LocalDateTime;

import java.util.ArrayList;
import java.util.List;

public class ExamsOverViewBackendMock implements ExamsOverViewBackend {

    public List<Subject> findSubjectsForUsername(String userName) {
        final List<Subject> list = new ArrayList<Subject>();

        final Subject par = new Subject("PAR");
        list.add(par);

        final Subject mpi = new Subject("MPI");
        list.add(mpi);

        final Subject tes = new Subject("TES");
        list.add(tes);

        return list;
    }

    @Override
    public Exam findExam(String examId) {
        return null;  //To change body of implemented methods use File | Settings | File Templates.
    }

//    public Subject findExam(String subjectId) {
//        if (subjectId.equals("1")) {
//            return new Subject("PAR");
//        } else if (subjectId.equals("2")) {
//            return new Subject("MPI");
//        } else if (subjectId.equals("3")) {
//            return new Subject("TES");
//        }
//        return null;  //To change body of implemented methods use File | Settings | File Templates.
//    }

    public List<Exam> findExamsForSubject(String subjectId) {
        final List<Exam> list = new ArrayList<Exam>();

        final LocalDateTime today = LocalDateTime.now();

        if (subjectId.equals("1")) {
            list.add(new Exam("1", "1", today.withTime(8, 0, 0, 0).plusDays(6)));
            list.add(new Exam("11", "1", today.withTime(8, 0, 0, 0).plusDays(13)));
            list.add(new Exam("111", "1", today.withTime(8, 0, 0, 0).plusDays(20)));
        }

        if (subjectId.equals("2")) {
            list.add(new Exam("2", "2", today.withTime(14, 0, 0, 0).plusDays(6)));
            list.add(new Exam("22", "2", today.withTime(14, 0, 0, 0).plusDays(13)));
            list.add(new Exam("222", "2", today.withTime(14, 0, 0, 0).plusDays(20)));
        }

        if (subjectId.equals("3")) {
            list.add(new Exam("3", "3", today.withTime(9, 30, 0, 0).plusDays(3)));
            list.add(new Exam("33", "3", today.withTime(9, 30, 0, 0).plusDays(10)));
            list.add(new Exam("333", "3", today.withTime(9, 30, 0, 0).plusDays(17)));
        }
        return list;
    }

    public boolean isUsernameValid(String username) {
        return true;
    }

    @Override
    public List<String> findExamIdsForUser(String username) {
        final List<String> list = new ArrayList<String>();
        list.add("1");
        list.add("22");
        list.add("333");
        return list;
    }

    @Override
    public List<Exam> findExamsForUser(String username) {
        return null;  //To change body of implemented methods use File | Settings | File Templates.
    }


}
